package cn.cmcc.intertelecom.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.cmcc.intertelecom.bean.Power;
import cn.cmcc.intertelecom.bean.PowerExample;
import cn.cmcc.intertelecom.bean.PowerExample.Criteria;
import cn.cmcc.intertelecom.dao.PowerMapper;

@Service
public class PowerService {
	
	@Autowired
	private PowerMapper powerMapper;

	/**
	 * 根据模块 id获取权限
	 * @param moduleId
	 * @return
	 */
	public List<Power> getPowerByoduleId(Integer moduleId) {
		PowerExample example=new PowerExample();
		Criteria criteria = example.createCriteria();
		criteria.andModuleIdEqualTo(moduleId);
	
		return powerMapper.selectByExample(example); 
	}

	/**
	 * 根据权限名称获取一个权限
	 * @param power
	 * @return
	 */
	public Power selectPowerByPowerStr(String power) {
		
		return powerMapper.selectByPowerStr(power);
	}
	
	public List<Power> selectPowerByPowerStrs(List<String> powers) {
		
		PowerExample example=new PowerExample();
		Criteria criteria = example.createCriteria();
		criteria.andPowerIn(powers);
		return powerMapper.selectByExample(example);
	}
	

}
